import { createRouter, createWebHistory } from 'vue-router'
import DetailPage from '../views/DetailPage.vue';
const routes = [
  {
    path: '/login',
    name: 'login',
    component: () => import(/* webpackChunkName: "about" */ '../views/login.vue')
  },
  {
    path: '/register',
    name: 'register',
    component: () => import(/* webpackChunkName: "about" */ '../views/register.vue')
  },
  {
    path: '/add-recipe',
    name: 'add-recipe',
    component: () => import(/* webpackChunkName: "about" */ '../views/addRecipe.vue')
  },
  {
    path: '/',
    component: () => import(/* webpackChunkName: "about" */ '../views/layout.vue'),
    meta:{
      // loginRequire:true
    },
    children:[{
        path: 'about',
        name: 'about',
        component: () => import(/* webpackChunkName: "about" */ '../views/AboutView.vue')
      },{
        path: 'main',
        name: 'main',
        component: () => import(/* webpackChunkName: "about" */ '../views/main.vue')
      }, {
        path: 'index',
        name: 'index',
        component: () => import(/* webpackChunkName: "about" */ '../views/index.vue')
      }, {
        path: 'recipelist',
        name: 'recipelist',
        component: () => import(/* webpackChunkName: "about" */ '../views/recipelist.vue')
      }, {
        path: 'recommend',
        name: 'recommend',
        component: () => import(/* webpackChunkName: "about" */ '../views/recommend.vue')
      }, {
        path: 'info',
        name: 'info',
        component: () => import(/* webpackChunkName: "about" */ '../views/userInfo.vue')
      }]
  },
  {
    path: '/detail/:recipeId',
    name: 'RecipeDetail',
    component: DetailPage,
    props: true // 将路由参数作为组件属性传递
  }
]

const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes
})

export default router
